package population;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import coalition.CoalitionWithInfo;
import coalition.CoalitionWithInfoInterface;


public class PopulationTestWithLargeSets {

	Population population;
	
	@Before
	public void setUp() throws Exception {
		population = (Population)Population.getNewPopulationInterface(new int[]{ 7, 6, 4, 8});
		
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testComputeCoalitions() {
		int counter = 0;
		List<CoalitionWithInfo> coalitionsWithInfo = population.computeCoalitions();
		/*
		for(Population.CoalitionWithInfo coalitionWithInfo : coalitionsWithInfo){
			System.out.println("Coalition " + counter);
			System.out.println("size:  " + coalitionWithInfo.getCoalitionSize());
			System.out.println("modulated size:  " + coalitionWithInfo.getCoalitionModulatedSize());
			System.out.println(coalitionWithInfo.getCoalition().toString());
			counter++;
		}
		*/
	}
	
	@Test
	public void testGetWinningCoalition() {
		CoalitionWithInfoInterface coalitionWithInfo = population.getWinningCoalition();
		if(coalitionWithInfo == null){
			System.out.println("no feasible winnning coalition"); return;
		}		
		System.out.println("Winning Coalition: ");
		System.out.println("size:  " + coalitionWithInfo.getCoalitionSize());
		System.out.println("modulated size:  " + coalitionWithInfo.getCoalitionModulatedSize());
		System.out.println("total population modulated size:  " + population.getTotalModulatedSize());
		System.out.println("fractional power:  " + 
				coalitionWithInfo.getCoalitionModulatedSize()/population.getTotalModulatedSize());
		System.out.println(coalitionWithInfo.getCoalition().toString());
	}	
	
	/*
	@Test
	public void testGetPreferredCoalitions() {
		int counter = 0;
		int[] indices = Population.getIndexArrayWithOneValue(population.dimensionSizes.length, 0, -1);
		List<int[]> allSectorIndices = RecursiveAccess.generateAllPermutations(indices, population.dimensionSizes);
		for(int[] sectorIndices: allSectorIndices){
			Population.CoalitionWithInfo coalitionWithInfo = population.getPreferredCoalition(sectorIndices);
			System.out.println("Sector: " + counter + "; indices: " + Population.printIntArray(sectorIndices));
			if(coalitionWithInfo == null){
				System.out.println("no feasible coalition"); counter++; continue;
			}
			System.out.println("preferred coalition size:  " + coalitionWithInfo.getCoalitionSize());
			System.out.println("preferred coalition modulated size:  " + coalitionWithInfo.getCoalitionModulatedSize());
			System.out.println("total population modulated size:  " + population.getTotalModulatedSize());
			System.out.println("fractional power:  " + 
					coalitionWithInfo.getCoalitionModulatedSize()/population.getTotalModulatedSize());
			System.out.println(coalitionWithInfo.getCoalition().toString());
			counter++;
		}
	}
	
	*/

}
